<!-- 已废弃 -->

<template>
  <div class="ruzhu">
    <el-form :model="dataForm" ref="dataForm" label-width="80px">
      <el-row>
        <el-col :span="9">
          <el-card shadow="hover" style="margin-bottom: 15px;">
            <div slot="header" class="clearfix"><span>订价信息</span></div>
            <div class="ant-card-body">
              <el-form-item label="入住类型" prop="checkinType">
                <!-- 入住类型（0全天1时租2自用3免费） -->
                <el-select v-model="dataForm.checkinType" @change="checkinTypeChange" placeholder="请选择">
                  <el-option label="全天" :value="0"></el-option>
                  <el-option label="时租" :value="1"></el-option>
                  <el-option label="自用" :value="2"></el-option>
                  <el-option label="免费" :value="3"></el-option>
                  <el-option label="长包" :value="4"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="预抵时间" prop="arrivalsTime">
                <el-row>
                  <el-col :span="12">
                    <el-date-picker disabled v-model="date.startDate1" value-format="yyyy-MM-dd" type="date"
                      placeholder="选择日期"></el-date-picker>
                  </el-col>
                  <el-col :span="12">
                    <el-time-select :clearable="false" v-model="date.startDate2" :picker-options="{
                        start: '00:00',
                        step: '00:01',
                        end: '23:55'
                      }"
                      placeholder="选择时间"></el-time-select>
                  </el-col>
                </el-row>
              </el-form-item>
              <el-form-item label="预离时间" prop="predissociationTime" v-if="dataForm.checkinType != 1">
                <el-row>
                  <el-col :span="12">
                    <el-date-picker :clearable="false" v-model="date.stopDate1" value-format="yyyy-MM-dd" @change="stopDate2Change"
                      :picker-options="pickerOptions" type="date" placeholder="选择日期"></el-date-picker>
                  </el-col>
                  <el-col :span="12">
                    <el-time-select :clearable="false" v-model="date.stopDate2" :picker-options="{
                        start: '00:00',
                        step: '00:5',
                        end: '23:55'
                      }"
                      placeholder="选择时间"></el-time-select>
                  </el-col>
                </el-row>
              </el-form-item>
              <el-form-item label="时长" prop="days" v-if="dataForm.checkinType == 1">
                <el-select v-model="dataForm.housId" @change="hoursChange" placeholder="请选择">
                  <el-option v-for="item in options.housOptions" :key="item.id" :label="item.name" :value="item.id"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item label="客人来源" prop="checkinType">

                <el-select v-model="dataForm.sourceAgreenid" placeholder="请选择">
                  <el-option v-for="item in userly" :key="item.id" :label="item.label" :value="item.id">
                  </el-option>
                </el-select>
              </el-form-item>

              <el-form-item label="早餐">
                <el-input-number :min="1" v-model="dataForm.zc" :step="1" step-strictly></el-input-number>
              </el-form-item>

              <el-form-item label="天数" v-if="dataForm.checkinType != 1">
                <el-input-number @change="daysChange" :min="1" v-model="dataForm.days" :step="1" step-strictly></el-input-number>
              </el-form-item>

              <el-form-item label="客人类型" prop="sourceType">
                <el-row>
                  <el-col :span="6">
                    <el-select v-model="dataForm.sourceType" placeholder="请选择">
                      <el-option v-for="item in sourceTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                  </el-col>
                  <el-col :span="8" style="margin-left: 10px;">
                    <el-select v-if="dataForm.sourceType == 1" @change="sellerMenberChange" v-model="dataForm.sourceName"
                      filterable remote reserve-keyword placeholder="姓名/手机号/身份证号" :remote-method="remoteMethod"
                      :loading="loading">
                      <el-option v-for="item in options.sellerMenberOp" :key="item.id" :label="item.name" :value="item.id"></el-option>
                    </el-select>
                    <el-input v-if="dataForm.sourceType == 3" v-model="dataForm.sourceName" placeholder="名称/简称/联系人"></el-input>
                    <el-select v-if="dataForm.sourceType == 2" @change="sellerxieyiChange" v-model="dataForm.sourceName"
                      filterable remote reserve-keyword placeholder="名称/编号/手机号" :remote-method="sellerxieyiChange"
                      :loading="loading">
                      <el-option v-for="item in listrestaurants" :key="item.values" :label="item.value" :value="item.values"></el-option>
                    </el-select>
                  </el-col>
                </el-row>
              </el-form-item>
              <el-form-item label-width="0" v-if="dataForm.sourceType == 2">
                <div class="customerSourceBar" style="margin-bottom: 0;">
                  <div>
                    <div class="in_block">
                      <label class="fourChar">姓名:</label>
                      <span v-cloak>{{rename}}</span>
                    </div>
                    <div class="in_block">
                      <label>电话:</label>
                      <label>{{retel}}</label>
                    </div>
                    <div class="in_block">
                      <label class="fourChar">余额:</label>
                      <span>{{recha}}</span>
                    </div>
                  </div>
                  <div>
                    <div class="in_block">
                      <label>预收款:</label>
                      <span>{{reyshouk}}</span>
                    </div>
                    <div class="in_block">
                      <label class="threeChar">已结算:</label>
                      <span>{{reweijs}}</span>
                    </div>
                    <div class="in_block">
                      <label class="threeChar">未结算:</label>
                      <span>{{reyjs}}</span>
                    </div>
                  </div>
                </div>
              </el-form-item>
              <el-form-item label-width="0" v-if="dataForm.sourceType == 1">
                <div class="customerSourceBar" style="margin-bottom: 0;">
                  <div>
                    <div class="in_block">
                      <label class="fourChar">姓名:</label>
                      <label>{{selectSellerMenber.name}}</label>
                    </div>
                    <div class="in_block">
                      <label>电话:</label>
                      <label>{{selectSellerMenber.tel}}</label>
                    </div>
                    <div class="in_block">
                      <label class="fourChar">级别:</label>
                      <label>{{selectSellerMenber.levelName}}</label>
                    </div>
                  </div>
                  <div>
                    <div class="in_block">
                      <label>储值:</label>
                      <label>{{selectSellerMenber.totalBalance}}</label>
                    </div>
                    <div class="in_block">
                      <label class="threeChar">积分:</label>
                      <label>{{selectSellerMenber.totalScore}}</label>
                    </div>
                    <div class="in_block">
                      <label class="threeChar">卡号:</label>
                      <label>{{selectSellerMenber.cardNo}}</label>
                    </div>
                  </div>
                </div>
              </el-form-item>
            </div>
          </el-card>
          <el-card shadow="hover" style="">
            <div slot="header" class="clearfix"><span>其他信息</span></div>
            <div class="ant-card-body">
              <el-row>
                <el-col :span="12">
                  <el-form-item label="担保方式">
                    <el-select v-model="dataForm.guaranteeType" placeholder="请选择">
                      <el-option v-for="item in guaranteeTypeOptions" :key="item.value" :label="item.label" :value="item.value"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="销售员">
                    <el-input v-model="dataForm.saleId" placeholder="销售员"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-form-item label="外部单号">
                <el-input v-model="dataForm.externalNo" placeholder="外部单号"></el-input>
              </el-form-item>
              <el-form-item label="备注">
                <el-input v-model="dataForm.remarks" placeholder="备注" type="textarea" :rows="2"></el-input>
              </el-form-item>
            </div>
          </el-card>
        </el-col>
        <el-col :span="15">
          <el-card shadow="hover" style="margin-bottom: 15px;">
            <div slot="header" class="clearfix"><span>办理入住</span></div>
            <div class="ant-card-body" v-loading="roomLoading" :element-loading-text="$t('Common.LoadingText')">
              <div class="title_day_price clear_float">
                <div class="pull">
                  <div style="cursor: pointer;">
                    <div class="in_block">
                      <span>房间数：</span>
                      <span>{{ addRoomsList.length }}间</span>
                    </div>
                    <div class="in_block">
                      <span>占房天数：</span>
                      <span>{{ dataForm.roomsDays }}晚</span>
                    </div>
                    <div class="in_block">
                      <span>总价：</span>
                      <span class="red_color1">￥ {{ dataForm.totalPrice.toFixed(2) }}</span>
                    </div>
                  </div>
                </div>
                <div class="push">
                  <el-button type="danger" size="small" @click="addRoomsBtn">添加房间</el-button>
                </div>
              </div>
              <div v-if="addRoomsList.length > 0">
                <div style="margin: 8px 0px;max-height: 300px;overflow-y: auto;">
                  <div v-for="(item, index) in addRoomsList" :key="index">
                    <div class="col_one clear_float" v-if="!item.prices.hoursMoney">
                      <div class="push" @click="removeRoom(item, index)"><a>删除房间</a></div>
                      <div class="pull">
                        <span style="display: inline-block;">801</span>
                        <span style="display: inline-block;">低层旭日海景大床房</span>
                        <span style="display: inline-block;">该房型不支持此入住类型</span>
                      </div>
                    </div>

                    <div class="col_one clear_float" v-if="item.prices.hoursMoney">
                      <div class="push">
                        <a @click="addpeople(item, index)">添加同住</a>
                        <div class="ant-divider ant-divider-vertical"></div>
                        <a type="text" @click="removeRoom(item, index)">删除房间</a>
                      </div>
                      <div class="pull">
                        <span>房号：{{ item.roomSign }}{{ item.roomNum }}</span>
                        <span>
                          房型：
                          <span style="display: inline-block;">{{ item.roomName }}</span>
                        </span>
                        <span>
                          <div>
                            <span style="color: rgb(232, 80, 80);">优惠价：</span>
                            <label>{{ item.prices.dateList[0][date.startDate1] }}</label>
                            <el-popover v-if="dataForm.checkinType != 1" placement="right" width="350" @show="editRoomPrice(item)"
                              trigger="hover">
                              <el-form label-width="100px" :inline="true" style="max-height: 300px !important;overflow-y: auto;">
                                <el-form-item v-for="(item, index) in setPrice.prices.dateList" v-if="index < dataForm.days"
                                  :key="setPrice.roomId + ':' + index" :label="dateList[index]">
                                  <el-input @change="changeTotalPrice(addRoomsList)" style="100px" size="small" v-model="item[dateList[index]]"
                                    placeholder="金额"></el-input>
                                </el-form-item>
                                <!--        <el-form-item v-for="i in setPrice.prices.length - 6" :key="i" :label="dateList[i-1]">
                                      <el-input size="small" v-model="setPrice.prices[dateList[i-1]]"></el-input>
                                    </el-form-item> -->
                              </el-form>
                              <i class="el-icon-edit" slot="reference" style="cursor: pointer;"></i>
                            </el-popover>
                            <!-- <i class="el-icon-edit" slot="reference" @click="editRoomPrice(item)" style="cursor: pointer;"></i> -->
                            <span style="margin-left: 5px; margin-right: 5px;">/</span>
                            <span>门市价：</span>
                            <label v-if="dataForm.checkinType == 1">{{ item.prices.dateList[0][date.startDate1] }}</label>
                            <label v-else>{{ item.roomPrice }}</label>
                          </div>
                        </span>
                      </div>
                    </div>

                    <div style="margin-top: 10px;" v-if="item.prices.hoursMoney">
                      <div style="margin-bottom: 10px;" v-for="(people, peopleIndex) in item.peoples" :key="peopleIndex">
                        <el-form-item class="in_block" label-width="0px" style="width: 13%;">
                          <el-input v-model="people.name" placeholder="姓名" size="small"></el-input>
                        </el-form-item>
                        <el-form-item class="in_block" label-width="0px" style="width: 10%;">
                          <el-select v-model="people.sex" placeholder="性别" size="small">
                            <el-option label="男" :value="1"></el-option>
                            <el-option label="女" :value="2"></el-option>
                          </el-select>
                        </el-form-item>
                        <el-form-item class="in_block" label-width="10px" style="width: 13%;">
                          <el-input v-model="people.tel" placeholder="手机号" size="small"></el-input>
                        </el-form-item>
                        <el-form-item class="in_block" label-width="0" style="width: 13%;">
                          <el-select v-model="people.type" placeholder="证件类型" size="small">
                            <el-option v-for="peopleType in options.peopleTypeOptions" :key="peopleType.value" :label="peopleType.label"
                              :value="peopleType.value"></el-option>
                          </el-select>
                        </el-form-item>
                        <el-form-item class="in_block" label-width="10px" style="width: 13%;">
                          <el-input size="small" v-model="people.number" placeholder="证件号"></el-input>
                        </el-form-item>

                        <el-form-item class="in_block" label-width="10px" style="width: 13%;">
                          <el-input v-model="people.address" placeholder="地址" size="small"></el-input>
                        </el-form-item>
                        <el-button size="small" class="in_block" style="margin-left: 20px;" @click="readIdCard(peopleIndex)">读取身份证</el-button>

                        <el-button size="small" class="in_block" v-if="peopleIndex != 0" @click="removePeople(item.peoples, people)">删除</el-button>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
              <div v-else>
                <div class="error_html">
                  <div class="text">点击上方按钮添加房间</div>
                </div>
              </div>
            </div>
          </el-card>
          <el-card shadow="hover" style="">
            <div slot="header" class="clearfix"><span>收款录入</span></div>
            <div class="ant-card-body">
              <div class="title_day_price clear_float">
                <div class="pull">
                  <div class="in_block">
                    <span>已收押金:</span>
                    <span>￥ {{ yajinPrice }}</span>
                  </div>
                  <div class="in_block">
                    <span>预收账款:</span>
                    <span>￥ {{ yushouPrice }}</span>
                  </div>
                  <div class="in_block">
                    <span>预授权:</span>
                    <span>￥ {{ authPrice }}</span>
                  </div>
                </div>
              </div>
              <el-tabs v-model="paysActiveName" @tab-click="paysHandleClick">
                <el-tab-pane label="收款" name="first">
                  <div v-for="(item, index) in nowpays" :key="index">
                    <el-tag type="danger" v-if="item.state == 1">押</el-tag>
                    <el-tag v-else>收</el-tag>
                    <el-form-item size="small" class="in_block" label-width="0">
                      <el-select v-model="item.nowType" placeholder="请选择">
                        <el-option v-for="item in options.paysTypeOptions" :key="item.name" :label="item.name" :value="item.id"></el-option>
                      </el-select>
                    </el-form-item>
                    <el-form-item size="small" class="in_block" label-width="10px">
                      <el-input @change="nowpaysChange" v-model="item.payPrice" placeholder="￥ 0.00"></el-input>
                    </el-form-item>
                    <el-button size="small" class="in_block" v-if="index != 0" @click="remPaysItem(item)">删除</el-button>
                    <el-button size="small" class="in_block" v-if="index == 0" @click="addPaysItem">添加收款</el-button>
                    <el-button size="small" class="in_block" v-if="item.state == 1" @click="setState(item, 2)">取消押金</el-button>
                    <el-button size="small" class="in_block" v-else @click="setState(item, 1)">标记押金</el-button>
                  </div>
                </el-tab-pane>
                <el-tab-pane label="信用卡预授" name="second">
                  <div v-for="(item, index) in yunowpays" :key="index">
                    <el-form-item size="small" class="in_block" label-width="10px">
                      <el-input v-model="item.bankNumber" placeholder="银行卡号"></el-input>
                    </el-form-item>
                    <el-form-item size="small" class="in_block" label-width="10px">
                      <el-input v-model="item.code" placeholder="预授权码"></el-input>
                    </el-form-item>
                    <el-form-item size="small" class="in_block" label-width="10px">
                      <el-input @change="yunowpaysChange" v-model="item.payPrice" placeholder="￥ 0.00"></el-input>
                    </el-form-item>
                    <el-button size="small" class="in_block" v-if="index != 0" @click="remyuPaysItem(item)">删除</el-button>
                    <el-button size="small" class="in_block" v-if="index == 0" @click="addyuPaysItem">添加收款</el-button>
                  </div>
                </el-tab-pane>
              </el-tabs>
            </div>
          </el-card>
        </el-col>
      </el-row>
      <div class="ant-layout-footer">
        <!-- <el-button @click="visible = false">{{ $t('Common.Cancel') }}</el-button> -->
        <el-checkbox v-model="printDengjiDan" style="margin-right: 10px;">打印入住登记单</el-checkbox>
        <el-button type="danger" @click="dataFormSubmit">入 住</el-button>
      </div>
    </el-form>

    <!-- 价格弹窗 -->
    <el-dialog title="价格修改" :visible.sync="priceVisible" :append-to-body="true">
      <el-form label-width="100px">
        <el-form-item v-for="(item, index) in setPrice.prices.dateList" v-if="index < dataForm.days" :key="setPrice.roomId + ':' + index"
          :label="dateList[index]">
          <el-input size="small" v-model="item[dateList[index]]" placeholder="金额"></el-input>
        </el-form-item>
        <!--        <el-form-item v-for="i in setPrice.prices.length - 6" :key="i" :label="dateList[i-1]">
            <el-input size="small" v-model="setPrice.prices[dateList[i-1]]"></el-input>
          </el-form-item> -->
      </el-form>
      <span slot="footer">
        <el-button @click="priceVisible = false">取消</el-button>
        <el-button type="primary" @click="dataFormSubmit()">{{ $t('Common.Confirm') }}</el-button>
      </span>
    </el-dialog>

    <!-- 选择房间-->
    <ruzhuFloorroomSelect v-if="ruzhuFloorroomSelectVisible" ref="ruzhuFloorroomSelect" @refreshDataList="refreshRoomList"></ruzhuFloorroomSelect>
  </div>
</template>

<script>
  import Vue from 'vue';
  import moment from 'moment';
  import ruzhuFloorroomSelect from './ruzhu-floorroom-select';
  export default {
    data() {
      return {
        printDengjiDan: false,
        roomLoading: false,
        selectMenberFlag: false,
        selectSellerMenber: {},
        loading: false,
        yajinPrice: 0,
        authPrice: 0,
        userly: [],
        yushouPrice: 0,
        newPrice: {},
        setPrice: {
          prices: {
            dateList: []
          }
        },
        ruzhuFloorroomSelectVisible: false,
        priceVisible: false,
        // 押金类型为现付（0AR帐1现金2储值卡3积分兑换4银行卡5支付宝6微信）
        options: {
          sellerMenberOp: [],
          housOptions: [],
          paysTypeOptions: [],
          peopleTypeOptions: [
            // 身份类型（0居民身份证1户口簿2军官证3警官证4士兵证5护照6其他）
            {
              label: '居民身份证',
              value: '0'
            },
            {
              label: '户口簿',
              value: '1'
            },
            {
              label: '军官证',
              value: '2'
            },
            {
              label: '警官证',
              value: '3'
            },
            {
              label: '士兵证',
              value: '4'
            },
            {
              label: '护照',
              value: '5'
            },
            {
              label: '其他',
              value: '6'
            }
          ]
        },
        nowpays: [{
          nowType: '',
          payPrice: '',
          state: 2
        }],
        yunowpays: [{
          bankNumber: '',
          code: '',
          state: 2,
          payPrice: ''
        }],
        paysActiveName: 'first',
        // （0散客1会员2协议单位3中介）
        pickerOptions: {
          disabledDate(time) {
            return time.getTime() < Date.now();
          }
        },
        addRoomsList: [],
        zidingyiSwitch: false,
        ruzhuZhang: true,
        sourceTypeOptions: [{
            label: '散客',
            value: 0
          },
          {
            label: '会员',
            value: 1
          },
          {
            label: '协议单位',
            value: 2
          },
          {
            label: '中介',
            value: 3
          }
        ],
        guaranteeTypeOptions: [{
            label: '无担保',
            value: 0
          },
          {
            label: '有担保',
            value: 1
          },
          {
            label: 'OTA担保',
            value: 2
          }
        ],
        date: {
          startDate1: moment().format('YYYY-MM-DD'),
          startDate2: moment().format('HH:mm'),
          stopDate1: moment()
            .add(1, 'days')
            .format('YYYY-MM-DD'),
          stopDate2: '12:00'
        },
        roomDayRule: {},
        housOptions: [],
        item: {},
        visible: false,
        dateList: [],
		istrues:0,
        dataForm: {
          housId: '',
          sellerId: '',
          userId: '',
          memberId: '',
          checkinType: 0,
          arrivalsTime: '',
          predissociationTime: '',
          days: 1,
          sourceType: 0,
          sourceName: '',
          sourceNames: '',
          activityId: '',
          guaranteeType: 0,
          saleId: '',
          externalNo: '',
          remarks: '',
          roomsNum: 0,
          roomsDays: 1,
          totalPrice: 0.0,
          creatTime: '',
          zc: 0,
          sourceAgreenid: '',
          agreemId: ''
        },
        dataRule: {
          sellerId: [{
            required: true,
            message: '商家不能为空',
            trigger: 'blur'
          }],
          userId: [{
            required: true,
            message: '操作人不能为空',
            trigger: 'blur'
          }],
          memberId: [{
            required: true,
            message: '会员不能为空',
            trigger: 'blur'
          }],
          checkinType: [{
            required: true,
            message: '入住类型（0全天1时租2自用3免费）不能为空',
            trigger: 'blur'
          }],
          arrivalsTime: [{
            required: true,
            message: '预抵时间不能为空',
            trigger: 'blur'
          }],
          predissociationTime: [{
            required: true,
            message: '预离时间不能为空',
            trigger: 'blur'
          }],
          days: [{
            required: true,
            message: '天数不能为空',
            trigger: 'blur'
          }],
          sourceType: [{
            required: true,
            message: '客源（0散客1会员2协议单位3中介）不能为空',
            trigger: 'blur'
          }],
          sourceName: [{
            required: true,
            message: '客源标记不能为空',
            trigger: 'blur'
          }],
          activityId: [{
            required: true,
            message: '市场活动不能为空',
            trigger: 'blur'
          }],
          guaranteeType: [{
            required: true,
            message: '担保方式（0无担保1担保2OTA担保）不能为空',
            trigger: 'blur'
          }],
          saleId: [{
            required: true,
            message: '销售不能为空',
            trigger: 'blur'
          }],
          externalNo: [{
            required: true,
            message: '外部单号不能为空',
            trigger: 'blur'
          }],
          remarks: [{
            required: true,
            message: '备注不能为空',
            trigger: 'blur'
          }],
          roomsNum: [{
            required: true,
            message: '房间数不能为空',
            trigger: 'blur'
          }],
          roomsDays: [{
            required: true,
            message: '占房天数不能为空',
            trigger: 'blur'
          }],
          totalPrice: [{
            required: true,
            message: '总价不能为空',
            trigger: 'blur'
          }],
          peopleName: [{
            required: true,
            message: '姓名不能为空',
            trigger: 'blur'
          }],
          peopleTel: [{
            required: true,
            message: '手机号不能为空',
            trigger: 'blur'
          }],
          peopleType: [{
            required: true,
            message: '身份类型不能为空',
            trigger: 'blur'
          }],
          peopleNumber: [{
            required: true,
            message: '身份证号不能为空',
            trigger: 'blur'
          }],
          creatTime: [{
            required: true,
            message: '创建时间不能为空',
            trigger: 'blur'
          }],

        },
        reindex: '',
        rename: '',
        retel: '',
        recha: '',
        reyshouk: '',
        reweijs: '',
        reyjs: '',
        listrestaurants: [],
        restaurants: []
      };
    },
    activated() {
      if (this.$cookie.get('ruzhuRoom')) {
        this.init(JSON.parse(this.$cookie.get('ruzhuRoom')));
      } else {
        this.init([]);
      }
      console.log(this.$cookie.get('printDengjiDan'))
      if (this.$cookie.get('printDengjiDan') != null) {
        if (this.$cookie.get('printDengjiDan') == 1) {
          this.printDengjiDan = true
        } else {
          this.printDengjiDan = false
        }
      }
    },
    components: {
      ruzhuFloorroomSelect
    },
    created() {
      this.getagreementType('userly');
      this.getList();
    },
    methods: {
      getagreementType(type) {
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelagreementtype/list'),
          method: 'get',
          params: this.$http.adornParams({
            page: 1,
            limit: 999,
            type: type
          })
        }).then(({
          data
        }) => {
          this.userly = data.page.list;
        });
      },
      init(list) {
        var arr = list;
        arr.forEach(item => {
          if (item.type == 1) {
            this.ruzhuZhang = false
          }
        })
        this.getPayTypes();
        this.getroomhours();
        this.searchRoomPriceGuiZe();
        this.visible = true;
        this.$nextTick(() => {
          this.getdateList();
          this.refreshRoomList(arr);
          this.$nextTick(()=>{
            console.log("开始时间",this.data.startDate2)
            var startNum = parseInt(this.data.startDate2.split(":")[0])
            console.log("开始时间",startNum)
            console.log("开始时间",startNum < 6)
            // if(startNum < 6)
          })
        });
      },
      //查询全天房计费规则
      searchRoomPriceGuiZe() {
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomdayrule/seller'),
          method: 'get',
          params: this.$http.adornParams({})
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            console.log(data);
            this.roomDayRule = data.tHotelFloorRoomDayRule
            this.date.stopDate2 = data.tHotelFloorRoomDayRule.exitPoint
          } else {
            this.roomDayRule = {};
          }
        });
      },
      getList() {

        this.$http({
          url: this.$http.adornUrl('/hotel/agreement/getdropdown'),
          method: 'post',
        }).then(({
          data
        }) => {

          this.restaurants = data.list;
          this.listrestaurants = data.list;
        });

      },
      sellerMenberChange(value) {
        console.log(value);
        var arr = this.options.sellerMenberOp.filter(item => item.id == value);
        this.selectSellerMenber = arr[0];
        this.selectMenberFlag = true;
        if (this.addRoomsList.length > 0) {
          this.reqRoomPrice(this.addRoomsList);
        }
      },
      sellerxieyiChange(value) {

        this.listrestaurants = [];
        console.log(value);
        var restaurants = this.restaurants;
        for (var i = 0; i < this.restaurants.length; i++) {
          var demo = restaurants[i].values;
          if (demo.indexOf(value) != -1) {
            this.dataForm.agreemId = restaurants[i].id

            this.rename = this.restaurants[i].name;
            this.retel = this.restaurants[i].tel;
            this.recha = this.restaurants[i].cha;
            this.reyshouk = this.restaurants[i].yshouk;
            this.reweijs = this.restaurants[i].wejies;
            this.reyjs = this.restaurants[i].yjs;
            this.listrestaurants.push(restaurants[i]);
          }
        }
      },
      remoteMethod(query) {
        if (query !== '') {
          this.loading = true;
          this.$http({
            url: this.$http.adornUrl('/hotel/hotelmemberleveldetail/list'),
            method: 'get',
            params: this.$http.adornParams({
              page: 1,
              limit: 999,
              ruzhuQuery: query
            })
          }).then(({
            data
          }) => {
            if (data && data.code === 0) {
              console.log(data);
              this.options.sellerMenberOp = data.page.records;
            } else {
              this.options.sellerMenberOp = [];
            }
            this.loading = false;
          });
        } else {
          this.options.sellerMenberOp = [];
        }
      },

      editRoomPrice(item) {
        this.setPrice = {};
        // this.priceVisible = true;
        this.newPrice = item;
        this.setPrice = {
          prices: {
            ...item.prices
          }
        };
      },
      //获取支付方式
      getPayTypes() {
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroompaytype/list'),
          method: 'get',
          params: this.$http.adornParams({
            page: 1,
            limit: 999,
			state: 1
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.options.paysTypeOptions = data.page.list;
          } else {
            this.options.paysTypeOptions = [];
          }
        });
      },
      //获取钟点房规则
      getroomhours() {
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomhours/list'),
          method: 'get',
          params: this.$http.adornParams({
            page: 1,
            limit: 999
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.options.housOptions = data.page.list;
          } else {
            this.options.housOptions = [];
          }
        });
      },
      addpeople(item, index) {
        item.peoples.push({
          name: '',
          tel: '',
          address: '',
          sex: 1,
          number: '',
          type: '0'
        });
      },
      removeRoom(item, index) {
        this.addRoomsList.splice(this.addRoomsList.indexOf(item), 1);
        this.$nextTick(() => {
          this.checkinTypeChange(this.dataForm.checkinType);
        });
      },
      removePeople(list, item) {
        list.splice(list.indexOf(item), 1);
      },
      refreshRoomList(val) {
        console.log(val);
        this.ruzhuZhang = true
        val.forEach(item => {
          if (item.type == 1) {
            this.ruzhuZhang = false
          }
          if (item.peoples.length == 0) {
            item.peoples.push({
              name: '',
              tel: '',
              sex: 1,
              address: '',
              number: '',
              type: '0'
            });
          }
        });
        this.addRoomsList = val;
        if (this.dataForm.checkinType == 1) {
          if (!this.dataForm.housId) {
            if (this.options.housOptions.length > 0) {
              this.dataForm.housId = this.options.housOptions[0].id;
            } else {
              this.$message.error('请设置钟点房计费规则');
            }
          }
          this.reqRoomHoursPrice(this.addRoomsList);
        }
        if (this.dataForm.checkinType == 0 || this.dataForm.checkinType == 2 || this.dataForm.checkinType == 3 || this.dataForm
          .checkinType == 4) {
          this.reqRoomPrice(this.addRoomsList);
        }
      },
      nowpaysChange() {
        this.yajinPrice = 0;
        this.yushouPrice = 0;
        this.authPrice = 0;
        this.nowpays.forEach(item => {
          if (item.state == 1) {
            this.yajinPrice += parseFloat(item.payPrice ? item.payPrice : 0);
          } else {
            this.yushouPrice += parseFloat(item.payPrice ? item.payPrice : 0);
          }
        });
      },
      yunowpaysChange() {
        this.yajinPrice = 0;
        this.yushouPrice = 0;
        this.authPrice = 0;
        this.yunowpays.forEach(item => {
          this.authPrice += parseFloat(item.payPrice ? item.payPrice : 0);
        });
      },
      setState(item, state) {
        item.state = state;
        this.nowpaysChange();
        this.$forceUpdate();
      },
      addPaysItem() {
        this.nowpays.push({
          nowType: '',
          payPrice: '',
          state: 2
        });
      },
      addyuPaysItem() {
        this.yunowpays.push({
          bankNumber: '',
          code: '',
          state: 2,
          payPrice: ''
        });
      },
      remPaysItem(item) {
        this.nowpays.splice(this.nowpays.indexOf(item), 1);
      },
      remyuPaysItem(item) {
        this.yunowpays.splice(this.yunowpays.indexOf(item), 1);
      },
      paysHandleClick(tab, event) {
        console.log(tab.index);
        const index = tab.index;
        this.yajinPrice = 0;
        this.yushouPrice = 0;
        //切换到现付收款
        if (index == 0) {
          this.nowpaysChange();
          //切换到预付款
        } else {
          this.yunowpaysChange();
        }
        console.log(tab, event);
      },
      addRoomsBtn() {
        this.ruzhuFloorroomSelectVisible = true;
        this.$nextTick(() => {
          this.$refs.ruzhuFloorroomSelect.init(this.addRoomsList);
        });
      },
      daysChange(val) {
        console.log(val);
        this.date.stopDate1 = moment()
          .add(val, 'days')
          .format('YYYY-MM-DD');
        this.dataForm.roomsDays = val;
        this.$nextTick(() => {
          this.getdateList();
          this.refreshRoomList(this.addRoomsList);
        });
      },
      checkinTypeChange(val) {
        if (val == 0 || val == 2 || val == 3) {
          this.refreshRoomList(this.addRoomsList);
        }
        if (val == 1) {
          if (!this.dataForm.housId) {
            if (this.options.housOptions.length > 0) {
              this.dataForm.housId = this.options.housOptions[0].id;
            } else {
              this.$message.error('请设置钟点房计费规则');
            }
          }
          this.reqRoomHoursPrice(this.addRoomsList);
        }
      },
      //加载日期
      getdateList() {
        this.dateList = [];
        //加载90天内日期
        for (var i = 0; i < this.dataForm.days; i++) {
          this.dateList.push(
            moment()
            .add(i, 'days')
            .format('YYYY-MM-DD')
          );
        }
      },
      hoursChange(hoursId) {
        console.log(hoursId);
        this.reqRoomHoursPrice(this.addRoomsList);
      },
      reqRoomHoursPrice(arr) {
        var idArr = [];
        arr.forEach((item, index) => {
          idArr.push(item.roomId);
        });
        var ids = idArr.join(',');
        this.$http({
          url: this.$http.adornUrl(`/hotel/thotelfloorroomhours/room_hours_money`),
          method: 'get',
          params: this.$http.adornParams({
            startDate: this.date.startDate1,
            endDate: moment()
              .add(1, 'days')
              .format('YYYY-MM-DD'),
            hoursId: this.dataForm.housId,
            roomIds: ids
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            console.log(data);
            for (var i = 0; i < this.addRoomsList.length; i++) {
              data.data.forEach((item, index) => {
                if (item.roomId == this.addRoomsList[i].roomId) {
                  let _obj = JSON.stringify(item),
                    objClone = JSON.parse(_obj);
                  this.addRoomsList[i].prices = objClone;
                  console.log(item);
                }
              });
            }
            this.changeTotalHoursPrice(this.addRoomsList);
          } else {
            this.$message.error(data.msg);
          }
        });
      },
      reqRoomPrice(arr) {
        this.roomLoading = true
        var idArr = [];
        arr.forEach((item, index) => {
          idArr.push(item.roomId);
        });
        var ids = idArr.join(',');
        this.$http({
          url: this.$http.adornUrl(`/hotel/hotelroomprice/list3`),
          method: 'get',
          params: this.$http.adornParams({
            startDate: this.date.startDate1,
            endDate: this.date.stopDate1,
            ids: ids
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            console.log(data);
            for (var i = 0; i < this.addRoomsList.length; i++) {
              data.data.dataList.forEach((item, index) => {
                if (item.roomId == this.addRoomsList[i].roomId) {
                  let _obj = JSON.stringify(item),
                    objClone = JSON.parse(_obj);
                  this.addRoomsList[i].prices = objClone;
                  console.log(item);
                }
              });
            }
            //会员折扣价
            if (this.selectMenberFlag) {
              this.addRoomsList.forEach((item, index) => {
                var arr = item.prices.dateList;
                for (var i = 0; i < this.dataForm.days; i++) {
                  arr[i][this.dateList[i]] = (parseFloat(arr[i][this.dateList[i]]) * parseFloat(this.selectSellerMenber
                    .discount)).toFixed(2)
                }
              });
            }
            //免费自用
            if (this.dataForm.checkinType == 2 || this.dataForm.checkinType == 3) {
              this.addRoomsList.forEach((item, index) => {
                var arr = item.prices.dateList;
                for (var i = 0; i < this.dataForm.days; i++) {
                  arr[i][this.dateList[i]] = 0
                }
              });
            }
            this.changeTotalPrice(this.addRoomsList);
          } else {
            this.$message.error(data.msg);
          }
          this.roomLoading = false
        });
      },
      //计算总金额
      changeTotalPrice(list) {
        var money = 0;
        if (this.dataForm.checkinType == 0) {
          list.forEach((item, index) => {
            var arr = item.prices.dateList;
            for (var i = 0; i < this.dataForm.days; i++) {
              money += parseFloat(arr[i][this.dateList[i]]);
            }
          });
        }
        this.dataForm.totalPrice = money;
      },
      //计算小时房总金额
      changeTotalHoursPrice(list) {
        var money = 0;
        list.forEach((item, index) => {
          console.log(item);
          var prices = item.prices;
          if (prices.hoursMoney) {
            var arr = item.prices.dateList;
            money += parseFloat(arr[0][this.dateList[0]]);
          }
        });
        this.dataForm.totalPrice = money;
      },
      stopDate2Change(val) {
        var startDate = moment(this.date.startDate1);
        var stopDate = moment(val);
        const date3 = stopDate.diff(startDate, 'day'); //计算相差的分钟数
        this.dataForm.days = date3;
        this.dataForm.roomsDays = date3;
        this.$nextTick(() => {
          this.getdateList();
          this.refreshRoomList(this.addRoomsList);
        });
      },
      toAccounting(item, type, printFlag) {
        //将数据存储到本地
        var p = {
          singleId: item.singleId,
          type: type,
          printFlag: printFlag,
        };
        this.$cookie.set('accounting', JSON.stringify(p));
        this.$router.push({
          name: 'accounting'
        });
      },


      /*
       * 读身份证
       * 参数 可选
       * Name: "张三"
       * Sex: "男"
       */
      readIdCard(index) {
        var CardEntity = {
          Name: "张三",
          Sex: "男"
        };
        var postData = {
          DeviceType: "IDCardHareware",
          Params: JSON.stringify(CardEntity)
        };
        this.Post(postData, "Read", index);
      },
      Post(postData, methods, index) {
        this.istrues=0;
        console.log(postData)
        var result;
        this.axios({
          url: this.axios.postUrl(`/api/Service/` + methods),
          method: 'POST',
          data: postData,
          cache: false,
          async: false,
          contentType: "application/json",
        }).then(({
          data
        }) => {
          this.istrues=1;
          if (data.isSuccess == true) {
            var peoples = {};
            peoples.name = data.Name
            if (data.Sex == "男") {
              peoples.sex = 1
            } else {
              peoples.sex = 2
            }
            peoples.type = "0"
            peoples.number = data.IDCardNumber
            peoples.address = data.Address
            console.log(this.addRoomsList)
            Vue.set(this.addRoomsList[0].peoples, index, peoples)
          } else {
            this.$message({
              message: data.message,
              type: "error",
              duration: 1500
            });
          }

        })



    },
	isputile(istrues,that){
     setTimeout(function(){
       if(istrues==0){
         that.$message({
           message: "接口程序未打开，请打开接口程序",
           type: "error",
           duration: 1500
         });
       }
     },2000);

	},
      // 表单提交
      dataFormSubmit() {
        console.log(this.dataForm)
        //检查是否勾选打印登记单
        var printState = 2;
        if (this.printDengjiDan) {
          printState = 1
          this.$cookie.set('printDengjiDan', 1)
        } else {
          this.$cookie.set('printDengjiDan', 2)
        }

        //检测是否有脏房
        if (!this.ruzhuZhang) {
          this.$confirm('入住房型有脏房，是否继续入住?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.ruzhuZhang = true;
            this.dataFormSubmit();
          })
          return false
        }
        for (var i = 0; i < this.addRoomsList.length; i++) {
          var item = this.addRoomsList[i];
          console.log(item);
          var prices = item.prices;
          //检测选中房间是否有不支持的
          if (!prices.hoursMoney) {
            this.$message.error('当前所选房间不支持办理入住！');
            return false;
          }
          //检测是否未填写姓名
          for (var j = 0; j < item.peoples.length; j++) {
            var pop = item.peoples[j];
            console.log(pop);
            if (!pop.name) {
              this.$message.error('入住人姓名必填！');
              return false;
            }
          }
        }
        this.$refs['dataForm'].validate(valid => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/hotel/thotelfloorroomcheckinsingle/ruzhu`),
              method: 'post',
              data: this.$http.adornData({
                id: this.dataForm.id || undefined,
                sellerId: this.dataForm.sellerId,
                userId: this.dataForm.userId,
                memberId: this.dataForm.memberId,
                checkinType: this.dataForm.checkinType,
                arrivalsTime: this.date.startDate1 + ' ' + this.date.startDate2,
                predissociationTime: this.date.stopDate1 + ' ' + this.date.stopDate2,
                days: this.dataForm.days,
                isDeposit: this.yajinPrice == 0 ? 0 : 1,
                sourceType: this.dataForm.sourceType,
                sourceName: this.dataForm.sourceName,
                activityId: this.dataForm.activityId,
                guaranteeType: this.dataForm.guaranteeType,
                housId: this.dataForm.housId,
                saleId: this.dataForm.saleId,
                externalNo: this.dataForm.externalNo,
                remarks: this.dataForm.remarks,
                roomsNum: this.addRoomsList.length,
                roomsDays: this.dataForm.roomsDays,
                totalPrice: this.dataForm.totalPrice,
                authPrice: this.authPrice,
                collectPrice: this.yushouPrice,
                depositPrice: this.yajinPrice,
                creatTime: this.dataForm.creatTime,
                zc: this.dataForm.zc,
                sourceAgreenid: this.dataForm.sourceAgreenid,
                agreemId: this.dataForm.agreemId,
                floorRooms: JSON.stringify(this.addRoomsList),
                paysType: this.paysActiveName == 'first' ? 0 : 1,
                nowpays: this.paysActiveName == 'first' ? JSON.stringify(this.nowpays) : JSON.stringify(
                  this.yunowpays)
              })
            }).then(({
              data
            }) => {
              if (data && data.code === 0) {
                Object.assign(this.$data, this.$options.data());
                this.$cookie.set('ruzhuRoom', '');
                //跳转账单界面
                this.toAccounting({
                  singleId: data.singleId
                }, '1', printState);
                this.$message({
                  message: this.$t('Common.OperationSuccessful'),
                  type: 'success',
                  duration: 1500,
                  onClose: () => {}
                });
              } else {
                this.$message.error(data.msg);
              }
            });
          }
        });
      }
    }
  };
</script>
<style>
  .ant-card-bordered,
  .ant-card-head,
  .ant-table-bordered table,
  .ant-table-bordered td,
  .ant-table-bordered th {
    border-color: #d9e5ec !important;
  }

  .ant-card-head-wrapper {
    display: flex;
    align-items: center;
  }

  .ant-card-head-title {
    display: inline-block;
    flex: 1 1;
    padding: 8px 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .ant-card-head:after {
    clear: both;
  }

  .ant-card-head:after,
  .ant-card-head:before {
    content: '';
    display: table;
  }

  .ant-card-body,
  .ant-card-wider-padding .ant-card-body {
    padding: 16px;
  }

  .ant-layout-footer {
    background: #fff;
    text-align: right;
    border-top: 1px solid #e8e8e8;
  }

  .ant-layout-footer {
    padding: 12px 24px;
    color: #002140;
    font-size: 14px;
    background: #d9e5ec;
    bottom: 0px;
    width: 100%;
    left: 0px;
  }

  .el-button+.el-button {
    margin-left: 8px;
  }

  .title_day_price {
    padding: 0 0 15px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  }

  .title_day_price>.pull {
    font-weight: 700;
    margin-top: 6px;
  }

  .pull {
    float: left;
  }

  .clear_float:after {
    display: block;
    content: '';
    clear: both;
  }

  .title_day_price>.pull .in_block+.in_block {
    margin-left: 30px;
  }

  .push {
    float: right;
  }

  .in_block {
    display: inline-block;
  }

  .title_day_price>.pull .in_block>span:first-of-type {
    color: #666;
  }

  .title_day_price>.pull .in_block>span:nth-of-type(2) {
    color: #151515;
  }

  .red_color1 {
    color: #f24e4c !important;
  }

  .error_html .text {
    font-size: 14px;
    margin-top: 20px;
    margin-bottom: 20px;
  }

  .error_html {
    text-align: center;
    color: #000;
  }

  .el-form-item.in_block {
    margin-bottom: 8px;
  }

  .el-form-item {
    margin-bottom: 15px;
  }

  .add_room_cell .col_one {
    padding: 10px 0;
  }

  .push {
    float: right;
  }

  .pull {
    float: left;
  }

  .push a:hover {
    text-decoration: none;
    cursor: pointer;
  }

  .ant-divider,
  .ant-divider-vertical {
    position: relative;
    top: -0.06em;
    display: inline-block;
    width: 1px;
    height: 0.9em;
    margin: 0 8px;
    vertical-align: middle;
  }

  .ant-divider {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    color: #002140;
    font-size: 14px;
    font-variant: tabular-nums;
    line-height: 1.5;
    list-style: none;
    -webkit-font-feature-settings: 'tnum', 'tnum';
    font-feature-settings: 'tnum', 'tnum';
    background: #e8e8e8;
  }

  .pull>span,
  .add_room_cell .col_two>.pull>span {
    display: inline-block;
  }

  .pull>span+span {
    margin-left: 30px;
  }

  .customerSourceBar {
    padding: 8px 16px;
    box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .09);
  }

  @media screen and (min-width: 1441px) {
    .customerSourceBar {
      margin-left: auto;
      margin-right: auto;
    }
  }

  .customerSourceBar>div>.in_block:nth-of-type(2) {
    width: 37%;
  }

  .customerSourceBar>div>.in_block:first-of-type {
    width: 26%;
  }

  .in_block {
    display: inline-block;
  }

  .ant-form label {
    font-size: 14px;
  }

  .ruzhu #pane-first {
    max-height: 150px;
    overflow-y: auto;
  }

  [v-cloak] {
    display: none;
  }
</style>
